package com.ziyun.pop.modules.mercharReport.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ziyun.pop.common.e.mercharReport.DirectionEnum;
import com.ziyun.pop.common.e.mercharReport.StoreInoutEnum;
import com.ziyun.pop.common.utils.EnumUtil;
import com.ziyun.pop.common.utils.JsonUtils;
import com.ziyun.pop.modules.mercharReport.dao.ReportStoreStockMaterialIoDao;
import com.ziyun.pop.modules.mercharReport.entity.ReportStoreStockMaterialIoVo;
import com.ziyun.pop.modules.mercharReport.service.ReportStoreStockMaterialIoService;
import io.renren.common.utils.R;
import org.apache.commons.lang3.EnumUtils;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;



@Service("reportStoreStockMaterialIoService")
public class ReportStoreStockMaterialIoServiceImpl extends ServiceImpl<ReportStoreStockMaterialIoDao, ReportStoreStockMaterialIoVo> implements ReportStoreStockMaterialIoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        Page<ReportStoreStockMaterialIoVo> page = (Page<ReportStoreStockMaterialIoVo>) this.page(
                new Query<ReportStoreStockMaterialIoVo>(params).getPage(),
                new QueryWrapper<ReportStoreStockMaterialIoVo>()
        );

        return new PageUtils(page);
    }

    @Override
    public R getlist(Map<String, Object> params) {
        Page<ReportStoreStockMaterialIoVo> page = new Page<>();
        page.setCurrent(Integer.valueOf(params.get("page").toString()));
        page.setSize(Integer.valueOf(params.get("limit").toString()));
        List<ReportStoreStockMaterialIoVo> list = this.baseMapper.list(page, params);
        page.setRecords(list);
        PageUtils pageUtils = new PageUtils(page);
        // 存放枚举类到userdata
        Map<String, List> mapEnum = new HashMap<>();
        mapEnum.put("storeInoutEnum",JsonUtils.enumToList(StoreInoutEnum.class));
        mapEnum.put("directionEnum",JsonUtils.enumToList(DirectionEnum.class));
        return R.ok().put("page", pageUtils).put("userData", mapEnum);
    }

    @Override
    public List<ReportStoreStockMaterialIoVo> exportExcel(Map<String, Object> params) {
        return  this.baseMapper.exportExcel(params);
    }

}
